package com.yyks.es.dubbo.pojo.vo;

import cn.hutool.core.collection.CollectionUtil;
import com.yeyks.hotel.dal.domain.HotelInfo;
import com.yeyks.hotel.dal.domain.RoomCalendarJipInfo;
import com.yeyks.hotel.dal.domain.RoomInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class HotelSearchJipSelectRoomCalendarVipInfoForOrderVo {

    private RoomInfo roomInfo;
    private HotelInfo hotelInfo;
    private List<RoomCalendarJipInfo> roomCalendarVipInfos;
    private Integer minCount;

    public Integer getMinPrice() {
        if (null != roomCalendarVipInfos && roomCalendarVipInfos.size() > 0) {
            List<Integer> count = CollectionUtil.getFieldValues(roomCalendarVipInfos, "salePrice", Integer.class);
            return count.stream().min((o1, o2) -> o1 - o2).get();
        }
        return null;
    }

    public Integer getMinCount() {
        try {
            if (CollectionUtil.isNotEmpty(roomCalendarVipInfos)) {
                Integer count = roomCalendarVipInfos.get(0).getCount();
                for (RoomCalendarJipInfo roomCalendarVipInfo : roomCalendarVipInfos) {
                    Integer count1 = roomCalendarVipInfo.getCount();
                    if (count > count1) {
                        count = count1;
                    }
                }
                return count;
            }
        } catch (Exception e) {
        }
        return 0;
    }

}
